﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace ELab.Serialization.Data
{
    [XmlRoot("Questions")]
    [Serializable]
    public class Question : IELabSerializable
    {
        [XmlElement("QuestionValue")]
        public string QuestionValue { get; set; }
        [XmlArray("Answers"), XmlArrayItem(typeof(Answer), ElementName = "Answer")]
        public Answer[] Answers { get; set; }

        public void Serialize(IELabSerializer serializer)
        {
            serializer.WriteStringUTF8(QuestionValue);
            serializer.WriteObjectArray(Answers);
        }

        public void Deserialize(IELabDeserializer deserializer)
        {
            QuestionValue = deserializer.ReadStringUTF8();
            Answers = deserializer.ReadObjectArray(() => new Answer());
        }
    }
}
